@layout("/common/_container.html"){
<div class="layui-card">
<div class="layui-card-body">
<div class="layui-form">
	<input type="hidden" name="msgConfigId" id="msgConfigId" value="${msgConfigId}">
	<input type="hidden" name="roleIds" id="roleIds">
	<table class="layui-table" id="table">
		  <thead>
		    <tr>
		      <th>管理员角色</th>
		      <th>角色描述</th>
		      <th>操作</th>
		    </tr> 
		  </thead>
		  <tbody>
		  	@for(role in roleList){
		  	<tr>
		      <th>${role.name}</th>
		      <th>${role.tips}</th>
		      <th><input type="checkbox" name="roleId" id="roleId" value="${role.id}" lay-filter="filter" lay-skin="primary" ${array.contain(roleIds,role.id)?'checked':''}></th>
		    </tr> 
		    @}
		  </tbody>
	</table>
	<div class="layui-hide">
		<input type="button" lay-submit lay-filter="msgConfig-submit" id="msgConfig-submit" value="确认">
	</div>
</div>
</div>
</div>


<script>
  layui.config({
	 base: Feng.ctxPath + '/static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form','laydate','table'], function(){
    var $ = layui.$
    ,form = layui.form
    ,table = layui.table
    ,laydate = layui.laydate;
    
    var roleIds = new Array();
    $("input:checkbox[name='roleId']:checked").each(function(i){
    	roleIds[i] = $(this).val();
    });
    $("#roleIds").val(roleIds.join(","));
    
    form.on('checkbox(filter)', function(data){
    	if(data.elem.checked){
    		roleIds.push(data.value);
    	}else{
    		roleIds.splice($.inArray(data.value,roleIds),1);
    	}
    	$("#roleIds").val(roleIds.join(","));
   	});
  })
  </script>
@}

